package com.greatwall.hip.cms.service.impl;

import com.greatwall.hip.cms.entity.LyPneumoniaDimension;
import com.greatwall.hip.cms.dao.LyPneumoniaDimensionDao;
import com.greatwall.hip.cms.model.DiseaseReq;
import com.greatwall.hip.cms.service.LyPneumoniaDimensionService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * 肺炎年龄性别维度表(LyPneumoniaDimension)表服务实现类
 *
 * @author makejava
 * @since 2021-07-08 15:01:57
 */
@Service("lyPneumoniaDimensionService")
public class LyPneumoniaDimensionServiceImpl implements LyPneumoniaDimensionService {
    @Resource
    private LyPneumoniaDimensionDao lyPneumoniaDimensionDao;

    /**
     * 通过ID查询单条数据
     *
     * @param id 主键
     * @return 实例对象
     */
    @Override
    public LyPneumoniaDimension queryById(Long id) {
        return this.lyPneumoniaDimensionDao.queryById(id);
    }

    /**
     * 查询多条数据
     *
     * @param offset 查询起始位置
     * @param limit  查询条数
     * @return 对象列表
     */
    @Override
    public List<LyPneumoniaDimension> queryAllByLimit(int offset, int limit) {
        return this.lyPneumoniaDimensionDao.queryAllByLimit(offset, limit);
    }

    /**
     * 新增数据
     *
     * @param lyPneumoniaDimension 实例对象
     * @return 实例对象
     */
    @Override
    public LyPneumoniaDimension insert(LyPneumoniaDimension lyPneumoniaDimension) {
        this.lyPneumoniaDimensionDao.insert(lyPneumoniaDimension);
        return lyPneumoniaDimension;
    }

    /**
     * 修改数据
     *
     * @param lyPneumoniaDimension 实例对象
     * @return 实例对象
     */
    @Override
    public LyPneumoniaDimension update(LyPneumoniaDimension lyPneumoniaDimension) {
        this.lyPneumoniaDimensionDao.update(lyPneumoniaDimension);
        return this.queryById(lyPneumoniaDimension.getId());
    }

    /**
     * 通过主键删除数据
     *
     * @param id 主键
     * @return 是否成功
     */
    @Override
    public boolean deleteById(Long id) {
        return this.lyPneumoniaDimensionDao.deleteById(id) > 0;
    }

    @Override
    public List<LyPneumoniaDimension> selectByDatesDuration(DiseaseReq diseaseReq) {
        return lyPneumoniaDimensionDao.selectByDatesDuration(diseaseReq);
    }

    @Override
    public LyPneumoniaDimension selectSumByDatesDuration(DiseaseReq diseaseReq) {
        return lyPneumoniaDimensionDao.selectSumByDatesDuration(diseaseReq);
    }
}
